Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC method to count the number of TX in the host #1919

Merged
merged 7 commits into from
May 16, 2024
Merged

Conversation

badgersrus
Copy link
Contributor

Why this change is needed

Moray needs the true value of the tx count for the e2e tests so we can check for overflow.
https://github.com/ten-protocol/ten-internal/issues/3377

What changes were made as part of this PR

  • New RPC-only method to run a count over the tx table

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

@badgersrus badgersrus requested a review from tudor-malene May 16, 2024 09:30
Copy link
Collaborator

@tudor-malene tudor-malene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.
(one small comment to add)

@@ -44,6 +44,8 @@ type BatchResolver interface {
FetchBatchByHeight(height *big.Int) (*common.PublicBatch, error)
// FetchTotalTxCount returns the number of transactions in the DB
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe explain in the comment the purpose of these 2 methods.
A fast but inaccurate one to be used for tenscan, and the other for testing

Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - except maybe distinguish a bit why the two methods are different (I guess the gist is you want a cached value because worried that row count is expensive but also want it to be ticking up for optics).

Personally I'm not sure the tx count should be persisted. If it's not been set in the last half hour or something it should query the count, and then in memory just count it up as batch txs come in. But this works for now so whatever's easier.

@@ -44,6 +44,8 @@ type BatchResolver interface {
FetchBatchByHeight(height *big.Int) (*common.PublicBatch, error)
// FetchTotalTxCount returns the number of transactions in the DB
FetchTotalTxCount() (*big.Int, error)
// FetchTotalTxsQuery returns the number of transactions in the DB
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to give this a different comment to the one above imo, clarify why these two identical looking methods exist a bit haha.

@badgersrus badgersrus merged commit a0d168c into main May 16, 2024
2 checks passed
@badgersrus badgersrus deleted the will/pagination-fix branch May 16, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants